import request from '@/utils/request'

// 获取组织架构数据
export function getDepartments() {
    return request({
        url: '/company/department',
        method: 'GET'
    })
}


/**
 * 删除部门
 * restful接口开发规范(后端) 
 *      CRUD 增删改查 Create read update delete 
 * @param {*} id  部门id
 */
export function delDepartments(id) {
    return request({
        url: `/company/department/${id}`,
        method: 'DELETE'
    })
}

/**
 * 添加部门
 * @param {*} data body参数  
 */
export function addDepartments(data) {
    return request({
        url: '/company/department',
        method: 'POST',
        data
    })
}


/**
 * 获取部门的详细信息 
 * @param {*} id 点击的部门id
 */
export function getDepartDetail(id) {
    return request({
        url: `/company/department/${id}`,
        method: "GET"
    })
}

export function updateDepartments(data) {
    return request({
        url: `/company/department/${data.id}`,
        method: 'PUT',
        data
    })
}
